<?php    
	
	global $dd_settings;
	$dd_settings = get_theme_support( 'cvincludes-dropdowns' );
	if(isset($dd_settings[0])) {		
		if ( in_array( 'longsubs', $dd_settings[0])) {					
			add_action('wp_head', 'cv_longsubs_head');
		}
			
		if ( in_array( 'navbar', $dd_settings[0])) {				
			add_action('wp_head', 'cv_navbar_head');
		}
			
		if ( in_array( 'vertical', $dd_settings[0])) {					
			add_action('wp_head', 'cv_vertical_head');
		}	
	}
	
	add_action( 'wp_enqueue_scripts', 'cv_dropdowns_scripts');	
	function cv_dropdowns_scripts() {
		global $dd_settings;
		wp_enqueue_script('jquery');
		wp_enqueue_script( 'dropdowns-superfish', trailingslashit(CVINCLUDES_DROPDOWNS_URI) . 'js/superfish.js', array( 'jquery' ));
		
		if ( in_array( 'longsubs', $dd_settings[0])) {			
			wp_enqueue_script( 'dropdowns-longsubs', trailingslashit(CVINCLUDES_DROPDOWNS_URI) . 'js/supersubs.js', array( 'jquery'));			
		}
	}
	
	add_action( 'wp_print_styles', 'cv_dropdowns_styles');	
	function cv_dropdowns_styles() {
		global $dd_settings;
		wp_enqueue_style( 'dropdowns-style', trailingslashit(CVINCLUDES_DROPDOWNS_URI) . 'css/superfish.css');	

		if ( in_array( 'navbar', $dd_settings[0])) {			
			wp_enqueue_style( 'dropdowns-navbar', trailingslashit(CVINCLUDES_DROPDOWNS_URI) . 'css/superfish-navbar.css');			
		}
			
		if ( in_array( 'vertical', $dd_settings[0])) {			
			wp_enqueue_style( 'dropdowns-navbar', trailingslashit(CVINCLUDES_DROPDOWNS_URI) . 'css/superfish-vertical.css');			
		}	
	}
	
	function cv_longsubs_head() { ?>		
		<script type="text/javascript" language="javascript">	
			jQuery.noConflict();		
			jQuery(document).ready(function(){ 
			jQuery("ul.sf-menu").supersubs({ 
				minWidth:    16,   // minimum width of sub-menus in em units 
				maxWidth:    27,   // maximum width of sub-menus in em units 
				extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
								   // due to slight rounding differences and font-family 
			}).superfish({ 
						speed: 'fast'   
						});                
							                
			}); 
		</script>
	<?php   
	}
	
	function cv_navbar_head() { ?>		
		<script type="text/javascript" language="javascript">	
			jQuery.noConflict();		
			jQuery(document).ready(function(){ 
				jQuery("ul.sf-menu").superfish({ 
					pathClass:  'current-menu-item',
					speed: 'fast'
				}); 
			}); 
		</script>
	<?php   
	}
	
	function cv_vertical_head() { ?>		
		<script type="text/javascript" language="javascript">	
			jQuery.noConflict();		
			jQuery(document).ready(function(){ 
				jQuery("ul.sf-menu").superfish({ 
				animation: {height:'show'},   // slide-down effect without fade-in 
				delay:     1200,               // 1.2 second delay on mouseout 
				speed: 'fast'
				}); 
			}); 
		</script>
	<?php   
	}

?>
